<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include::header"></head>

<body class="gray-bg">
	<div class="wrapper wrapper-content animated fadeInRight">
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-title">
						<h5></h5>
					</div>
					<div class="ibox-content">
						<div class="form-horizontal m-t" id="signupForm">
							<input id="inputId" name="inputId" th:value="${inputId}" type="hidden">
							<input id="imgId" name="imgId" th:value="${imgId}" type="hidden">
							<div class="form-group">
								<label class="col-sm-2 control-label"></label>
								<div class="col-sm-8">
									<input id="fileupload" name="file" class="form-control" type="file"
										accept="image/*">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label"></label>
								<div id="progress">
									<div class="bar" style="width: 0%;height: 3px;background-color: #00B83F"></div>
								</div>
							</div>
<!--							<span class="lbl col-xs-12 col-sm-6">-->
										<span style="margin: 200px;color:#ff0000;">*图片上传格式大小不能超过1MB</span>
<!--									</span>-->
							<div class="form-group text-center">
								<div class="col-sm-8 col-sm-offset-2">
									<div class="btn btn-danger" onclick="closeDow()"><i class="fa fa-remove"></i> 关闭</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div th:include="include::footer"></div>
	<script type="text/javascript" src="/js/plugins/jquery-file-upload/jquery.ui.widget.js"></script>
	<script type="text/javascript" src="/js/plugins/jquery-file-upload/jquery.iframe-transport.js" ></script>
	<script type="text/javascript" src="/js/plugins/jquery-file-upload/jquery.fileupload.js" ></script>
	<script type="text/javascript">
		/**
		 * Created by kanghaixin on 2016/11/23.
		 */
		$(function () {
			var inputId = $('#inputId').val();
			var imgId = $('#imgId').val();

			var url = '/platform/config/upload2';
			$('#fileupload').fileupload({
				url: url,
				dataType: 'JSON',
				acceptFileTypes: /(\.|\/)(gif|jpe?g|png|rmvb|avi|mpg|mp4)$/i,
				done: function (e, data) {
					var result = data.result;
					if(result) {
						if (result.code == 0) {
							parent.loadImgUrl(inputId, imgId, result.key);
						}else if(result.code == -1){
							parent.layer.msg(result.msg,{icon:7})
						}
					}
					closeDow();
				},
				progressall: function (e, data) {
					var progress = parseInt((data.loaded / data.total) * 100, 10);
					$('#progress .bar').css('width', progress + '%');
					if (progress === 100) {
						parent.layer.msg('上传完成!',{icon:6})
					}

				}
			}).prop('disabled', !$.support.fileInput).parent().addClass($.support.fileInput ? undefined : 'disabled');
		});
	</script>
	<script type="text/javascript">
		function closeDow() {
			var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
			parent.layer.close(index);
		}
	</script>
</body>

</html>
